function test(){
	ApplicationKeyDWRService.searchJsonApplicationKey(callBackResult);
 }
function callBackResult(result) {
	  var arg=eval(result);
	  var appkey='';
	  for(i=0;i<arg.length;i++)
		  {
		  appkey=appkey+arg[i].appkey;
		     
		  }
	  alert(appkey);
}
function cleanApplicationKey()
{
	document.getElementById("applicationedit:txtindex").value="";
	document.getElementById("applicationedit:txtid").value="";
	document.getElementById("applicationedit:txtappkey").value="";
	document.getElementById("applicationedit:txtdefaultvalue").value="";
	document.getElementById("applicationedit:txtdescription").value="";
	showLayer('1');
}
function deleteAppkey(dom,index)
{
	if (window.confirm("Are you sure delete the application key?")) {
		var appkeyid=document.getElementById("radiotable_tr_td_appkeyid_"+index).innerHTML;
		ApplicationKeyDWRService.delJsonApplicationKey(appkeyid,function(data){callbackdel(data,index);});
		
    }	
	
	return false;
}
var callbackdel =function callBackResultDel(result,index) {
	  var arg=eval(result);
	  if(arg>0)
	  {		 
		  var row=document.getElementById("radiotable_tr_"+index); 
		  $(row).remove(); 
	  }
};

function findApplicationkey(dom,index)
{
	
	//get the table first td's value
	var appkeyid=document.getElementById("radiotable_tr_td_appkeyid_"+index).innerHTML;
	ApplicationKeyDWRService.findJsonApplicationKey(appkeyid,function(data){callbackFind(data,index);});
}
var callbackFind =function callBackResultfind(result,index)
{
	
	var arg=eval(result);
	
	document.getElementById("applicationedit:txtindex").value=index;
	document.getElementById("applicationedit:txtid").value=arg.id;
	document.getElementById("applicationedit:txtappkey").value=arg.appkey;
	document.getElementById("applicationedit:txtdefaultvalue").value=arg.defaultvalue;
	document.getElementById("applicationedit:txtdescription").value=arg.description;
	showLayer('1');
};


function cleanAppliccationKeyValue()
{
	
}

function onclickRowApplicationkey(index)
{
	
	//get the table first td's value
	var APPKEYID=document.getElementById("radiotable_tr_td_appkeyid_"+index).innerHTML;
	document.getElementById("hidApplicationKeyID").value=APPKEYID;
	searchAllApplicationKeyValue(APPKEYID);
	
}

function cleanAppliccationKeyValue()
{
	document.getElementById("txtapplicationkeyvalueid").value="";
	document.getElementById("txtapplicationkeyvaluevalue").value="";
	document.getElementById("txtapplicationkeyvaluedescription").value="";
	showLayer('2');
}
function searchAllApplicationKeyValue(APPKEYID)
{
	ApplicationKeyDWRService.searchJsonApplicationKeyValueByID(APPKEYID,function(data){callbackonclickrow(data);});
}
var callbackonclickrow =function callBackResultonclick(result)
{
	
	$("#childtbody").empty();
	var arg=eval(result);
	
	var stringHtml="";
	if(arg!="")
	{
		for(i=0;i<arg.length;i++)
		{		
			var item=eval(arg[i]);
			stringHtml=stringHtml+"<tr id='appkeyvalue_tr_"+item.id+"'><td style='display:none'>"+item.id+"</td><td id='appkeyvalue_tr_value_"+item.id+"'>"+item.value+"</td><td id='appkeyvalue_tr_valuedescription_"+item.id+"'>"+item.valuedescription+"</td><td><a href=\"javascript:void(0);\"><img src=\"../../resources/images/btn_edit.gif\" onclick=\"findApplicationKeyValue('"+item.id+"')\"></img></a><a href=\"javascript:void(0);\"><img src=\"../../resources/images/btn_remove.gif\" onclick=\"delApplicationKeyValue('"+item.id+"')\"></img></a></td></tr>"
			
		}
		$("#childtbody").prepend(stringHtml);
		(new DataTable("applicationkeyvaluetable")).init();
	}
	
	document.getElementById("childshowtr").style.display="";
};
function delApplicationKeyValue(appkeyvalueid)
{
	if (window.confirm("Are you sure delete the application key value?")) {
		
		ApplicationKeyDWRService.delJsonApplicationKeyValue(appkeyvalueid,function(data){callbackappkeyvaluedel(data,appkeyvalueid);});
		
    }	
	
	return false;
}
var callbackappkeyvaluedel=function callBackResultappkeyvaluedel(result,appkeyvalueid)
{
	if(result>0)
	{
		var row=document.getElementById("appkeyvalue_tr_"+appkeyvalueid);
		$(row).remove();
	}
};
function findApplicationKeyValue(appkeyvalueid)
{
	ApplicationKeyDWRService.findJsonApplicationKeyValue(appkeyvalueid,function(data){callbackappkeyvaluefind(data);});
}
var callbackappkeyvaluefind=function callBackResultappkeyvaluefind(result)
{
	var arg=eval(result);
	document.getElementById("txtapplicationkeyvalueid").value=arg.id;
	document.getElementById("txtapplicationkeyvaluevalue").value=arg.value;
	document.getElementById("txtapplicationkeyvaluedescription").value=arg.valuedescription;
	showLayer('2');
};

function addAppKeyValue()
{
	
	var id=document.getElementById("txtapplicationkeyvalueid").value;
	var value=document.getElementById("txtapplicationkeyvaluevalue").value;
	var valuedescription=document.getElementById("txtapplicationkeyvaluedescription").value;
	var appkeyid=document.getElementById("hidApplicationKeyID").value;
	var applicationkeyvalue = { id:id,appkeyid:appkeyid,value:value,valuedescription:valuedescription};
	ApplicationKeyDWRService.addJsonApplicationKeyValue(applicationkeyvalue,function(data){callbackaddapplicationkeyvalue(data);});
	closeLayer('2');
    
}
var callbackaddapplicationkeyvalue=function callBackResultAddApplicationKeyValue(result)
{
	var appkeyid=document.getElementById("hidApplicationKeyID").value;
	if(result>0)
	{
		searchAllApplicationKeyValue(appkeyid);
		alert("save success!");
	}else{
		alert("save fail!");
	}
};






